Skip to content

Fix hanging during SSL_write for large packets#3105

Merged
old-bear merged 2 commits into
apache:masterfrom
old-bear:remove-bio
Sep 24, 2025
Merged

Fix hanging during SSL_write for large packets#3105
old-bear merged 2 commits into
apache:masterfrom
old-bear:remove-bio

Conversation

@old-bear

@old-bear old-bear commented Sep 23, 2025

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Issue Number:

Problem Summary:
When sending large packet under SSL, brpc could stuck as data still resides in BIO buffer.

What is changed and the side effects?

Changed: Disable BIO for SSL for 2 reasons:

  1. The current implementation makes it very hard to handle EAGAIN from both SSL_write and BIO_flush.
  2. BIO is optional and kind of outdate for modern TCP, which already has buffer mechanism.

Side effects:

  • Performance effects: Should be no impact

  • Breaking backward compatibility: No


Check List:

@old-bear old-bear changed the title Remove BIO for SSL Fix hanging during SSL_write for large packets Sep 23, 2025
@wwbmmm

wwbmmm commented Sep 23, 2025

Copy link
Copy Markdown
Contributor

LGTM

@chenBright chenBright linked an issue Sep 23, 2025 that may be closed by this pull request
@chenBright

Copy link
Copy Markdown
Contributor

Is BIO_flush still needed?

brpc/src/butil/iobuf.cpp

Lines 934 to 939 in 7229c36

if (BIO_wpending(wbio) > 0) {
int rc = BIO_flush(wbio);
if (rc <= 0 && BIO_fd_non_fatal_error(errno) == 0) {
// Fatal error during BIO_flush
*ssl_error = SSL_ERROR_SYSCALL;
return rc;

@old-bear

Copy link
Copy Markdown
Contributor Author

Is BIO_flush still needed?

brpc/src/butil/iobuf.cpp

Lines 934 to 939 in 7229c36

if (BIO_wpending(wbio) > 0) {
int rc = BIO_flush(wbio);
if (rc <= 0 && BIO_fd_non_fatal_error(errno) == 0) {
// Fatal error during BIO_flush
*ssl_error = SSL_ERROR_SYSCALL;
return rc;

No. BIO_wpending will return 0, so this code will not be reached. For clarity, I have commented out the code and left a note.

@old-bear old-bear merged commit 020f807 into apache:master Sep 24, 2025
16 checks passed
chenBright pushed a commit to chenBright/brpc that referenced this pull request Sep 28, 2025
Fix hanging during SSL_write for large packets
chenBright pushed a commit to chenBright/brpc that referenced this pull request Sep 28, 2025
Fix hanging during SSL_write for large packets
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

openssl短连接方式访问服务,偶发E1008超时错误

3 participants